﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Infrastructure;
using Enterprise.Model.Article;
using Enterprise.Service.Article;
namespace Enterprise.UI.Web.Modules.Article
{
    public partial class Details : Enterprise.Service.BasePage
    {
        protected int Id = (int)Utility.sink("Id", Utility.MethodType.Get, 0, 0, Utility.DataType.Int);
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                OnStart();
                OnRefreshRecevie();
            }
        }

        /// <summary>
        /// 初始化数据内容
        /// </summary>
        private void OnStart()
        {
            ArticleService aService = new ArticleService();
            var q = aService.ArticleDisp(Id);
            if (q != null)
            {
                lb_Title.Text=Page.Title = q.ATitle;
                lb_TitleRu.Text = q.ATitleRu;
                lb_User.Text = Enterprise.Service.User.UserService.GetUserName(q.ACreateUser);
                lb_CreateTime.Text = q.AReleaseTime.ToShortDateString();
                lb_Content.Text = q.AContent;
                lb_ContentRu.Text = q.AContentRu;                
            }
        }

        /// <summary>
        /// 绑定签收人
        /// </summary>
        private void OnRefreshRecevie()
        {
            ArticleRecevieService arService = new ArticleRecevieService();
            if (!arService.ArticleRecevieCheck(Id, Utility.Get_UserId))
            {
                ArticleRecevieEntity entity = new ArticleRecevieEntity();
                entity.InfoId = Id;
                entity.RUserId = Utility.Get_UserId;
                entity.RDateTime = DateTime.Now;
                entity.DB_Option_Action = "Insert";
                arService.ArticleRecevieExecute(entity);
            }
        }


    }
}